home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0885.arc
/
LOGIC1.LTG
< prev
next >
Wrap
Text File
|
1986-02-27
|
1KB
|
43 lines
Listing 1
length of only one
'\n'
BACKSPACE
except when i = 0; á/* no input */
NUMERIC typ
require numbers for input
length exhausted
Therefore, áour conditions become :
length == 1 ááááááè c == '\n' ááááááá
c == BACKSPACE áá
i == 0 ááááááá
typ == NUMERIC áá
isdigit(c) áá
i == length
The things we're supposed to do on various conditions are
ring the bell on errors
echo the characters typed
store the characters typed in the string provided
implied is proper termination of the string
and keeping track of where the current char is
backup on legal BACKSPACEs
return when finished
ì
Therefore, áour conditions map as follows:
beep() á
addch(c);refresh() ááá/* 'curses' screen update */
str[i] = c ááááá
str[i+1]='\0'
backup(1) áááááá/* function that manages a backup */
i++
break áááááááááá/* we'll assume an infinite loop */